package org.hxyjs.controller;

import org.hxyjs.dto.DTO;
import org.hxyjs.entity.Activitytype;
import org.hxyjs.entity.Activitytype;
import org.hxyjs.page.PageInfo;
import org.hxyjs.service.ActivitytypeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@Controller
@RequestMapping("/activitytypeController")
public class ActivitytypeController {
	@Resource
	ActivitytypeService activitytypeService;
	@RequestMapping("/getAllActivitytype")
	@ResponseBody //把方法的返回值按json转换之后 输出到浏览器
    public DTO<Activitytype> getAllActivitytype() throws Exception {
    	System.out.println("查询全部活动类型");
		return activitytypeService.getAllActivitytypes();
    }

	@RequestMapping("/deleteActivitytypeByAtno/{atno}")
	@ResponseBody
    public DTO<Activitytype> deleteActivitytypeByAtno(@PathVariable("atno") String atno) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
    	System.out.println(atno+"删除活动类型");
    	return activitytypeService.deleteActivitytypeByAtno(atno);
    }

	@RequestMapping("/updateActivitytypeByAtno")
	@ResponseBody
	public DTO<Activitytype> updateActivitytypeByAtno(@RequestBody Activitytype activitytype) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("修改活动类型");
		return activitytypeService.updateActivitytypeByAtno(activitytype);
	}


	@RequestMapping("/addActivitytype")
	@ResponseBody
	public DTO<Activitytype> addActivitytype(@RequestBody Activitytype activitytype) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("增加活动类型");
		System.out.println(activitytype);
 		return activitytypeService.addActivitytype(activitytype);
	}
	@RequestMapping("/getActivitytypeByPage")
	@ResponseBody
	public DTO<Activitytype> getActivitytypeByPage(PageInfo pageInfo) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("分页活动类型");
		return activitytypeService.getActivitytypeByPage(pageInfo);
	}

}